package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.SysLogMapper;
import com.itheima.pojo.SysLog;
import com.itheima.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    @Override
    public Page<SysLog> getLogList(SysLog sysLog) {
        PageHelper.startPage(sysLog.getCurrentPage(),sysLog.getPageSize());
        String operation = sysLog.getOperation();
        if (operation.equals("")) {
            sysLog.setOperation(null);
        }
        String userName = sysLog.getUserName();
        if (userName.equals("")) {
            sysLog.setUserName(null);
        }
        List<SysLog> sysLogList = sysLogMapper.select(sysLog);

        return (Page<SysLog>) sysLogList;
    }
}
